#include <iostream>
using namespace std;
int main()
{
	int a[100],i,top=0;
	char ch;
	while(cin>>ch)
	{
		if(ch=='#')break;
		if(ch>='0'&&ch<='9')
			a[++top]=ch-'0';
		else
		{
			int y=a[top--];
			int x=a[top--];
			if(ch=='+')a[++top]=x+y;
			else if(ch=='-')a[++top]=x-y;
			else if(ch=='*')a[++top]=x*y;
			else if(ch=='/')a[++top]=x/y;
		}
		
	}
	cout<<a[top];
	return 0;
}